-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: link launch dir with existing nucleus package if does not exist #1675
Conversation
Binary incompatibility detected for commit a2ecf14. com.aws.greengrass.lifecyclemanager.KernelAlternatives is binary incompatible and is source incompatible because of CONSTRUCTOR_REMOVED Produced by binaryCompatability.py |
Unit Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against a2ecf14 |
Integration Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against a2ecf14 |
Path currentDir = getCurrentDir(); | ||
if (!Files.isSymbolicLink(currentDir)) { | ||
throw new DirectoryValidationException("Missing symlink to current nucleus launch directory"); | ||
if (!Files.isSymbolicLink(getCurrentDir())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if current exists but loader path does not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am finding it hard to imagine a scenario where current points to a valid Nucleus package but loader does not exist in that package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current exist does not mean that current points to a valid package though
} | ||
|
||
List<Path> localNucleusExecutablePaths = componentManager.findValidLocalNucleusPackage(); | ||
if (!localNucleusExecutablePaths.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't you calling isEmpty on null object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. This will still be an empty check in case artifacts dir is empty (initial installation) but this code path should only hit if a customer purposefully deletes the loader script from the unarchived dir. Imo, this is low risk.
1f77429
to
4b3ae05
Compare
src/main/java/com/aws/greengrass/lifecyclemanager/KernelAlternatives.java
Show resolved
Hide resolved
760825c
to
0f4b820
Compare
try { | ||
Path unarchivePath = | ||
nucleusPaths.unarchiveArtifactPath(nucleusComponentIdentifier, getFileName(file)); | ||
unarchiver.unarchive(Unarchive.ZIP, file, unarchivePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if the archive file exists on the disk before unarchiving?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not necessary, if the file does not exist, unarchiver will throw an IOException which ComponentManager will catch and just return null. The stream will filter out nonNull objects later on. If no artifact file existed then the list returned by ComponentManager will be empty and KernelAlternatives will handle that appropriately.
.map(file -> { | ||
try { | ||
Path unarchivePath = | ||
nucleusPaths.unarchiveArtifactPath(nucleusComponentIdentifier, getFileName(file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that we have zip artifacts only in the nucleus component versions, but this line would always copy over the artifacts to unarchived-artifacts folder irrespective of the Unarchive type of the artifact in the recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, since this code path is used only for Nucleus artifacts in the near future, I do not see a harm in hard coding the unarchive as ZIP. But I can modify to fetch unarchive from the recipe if you have a strong opinion on it.
Issue #, if available:
Description of changes:
Re create (if not present) and re link the current launch directory symbolic link with the Nucleus package which is currently being executed. This will only be executed if the current launch directory symbolic link does not exist.
If the current Nucleus package in execution does not have a loader file in its un-archived path, un-archive the the current Nucleus package artifact to re-populate the loader paths.
Why is this change necessary:
This change is necessary to mitigate deployment failures due to Launch Dir Corrupted.
How was this change tested:
Any additional information or context required to review the change:
Documentation Checklist:
Compatibility Checklist:
any deprecated method or type.
Refer to Compatibility Guidelines for more information.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.